﻿// <copyright file="action_newsList.aspx.cs" company="NTalent">
// Copyright (c) 2010, NTalent, Inc. All rights reserved
// </copyright>
// <author>卢俊坤</author>
// <author>王彦博 符茂松</author>

using System;
using System.Web.UI.WebControls;
using Net.Ntalent.Action50.Core.Controls;
using Net.Ntalent.Action50.Core.Service;
using Net.Ntalent.Action50.Core.Util;
using Net.Ntalent.Action50.DataAccess;

/// <summary>
/// 显示某个action的news列表的页面
/// </summary>
///<author>王彦博</author> 
/// <copyright>
/// Copyright (c) 2010, NTalent, Co. Ltd. All rights reserved.
/// </copyright>
/// <version>1.0.0</version>   
public partial class action_newsList : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[Constants.SESSION_KEY_ADMIN_NAME] == null)
        {
            Li_Admin.Visible = false;
            Li_Login.Visible = true;
        }
        else
        {
            Li_Admin.Visible = true;
            Li_Login.Visible = false;
        }

        if (Helper.getQueryString(Context, "actionId") == string.Empty)
        {
            //如果查询字符串中没有actionId
            return;
        }

        long actionId = Convert.ToInt64(Helper.getQueryString(Context, "actionId"));
        ReadOnlyService readOnlyService = new ReadOnlyService();

        //加载团队照片,团队介绍
        {
            T_ACTIONS action = readOnlyService.RetrieveAction(actionId);
            Literal_actionShortIntro.Text = action.SHORT_INTRO;
            long landScapeId = Helper.getActionLandscapeId(action.Id);
            if (landScapeId == 0)
            {
                //若该action尚无landscape,则显示默认图片
                Image_actionLandScape.ImageUrl = Helper.DEFAULT_LANDSCAPE;
            }
            else
            {
                Image_actionLandScape.ImageUrl = 
                    "Handlers/GallaryHandler.ashx?action=getImage&id=" + landScapeId;
            }
        }

    }

    protected void ListView_contentDetails_DataBound(object sender, EventArgs e)
    {
        //如果数据不够一页，则不显示分页控件。
        var readOnlyService = new ReadOnlyService();
        long newsCount = readOnlyService.RetrieveAcitonNews(Convert.ToInt64(Helper.getQueryString(Context, "actionId"))).Count;
        if (newsCount <= 5)
        {
            DataPager1.Visible = false;
        }
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        new AuthenticationService().LogOut();
        Response.Redirect(Request.UrlReferrer.ToString());
    }
}
